home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 3 / Amiga Format CD03 (1996-07-04)(Future Publishing)(GB)(Track 1 of 6)[!][issue 1996-08].iso / comms / netsoftware / nethandler.lha / NetHandler / handler / netdnet.c < prev    next >
C/C++ Source or Header  |  1989-09-16  |  3KB  |  128 lines

  1. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\
  2. * |_o_o|\\ Copyright (c) 1988 The Software Distillery.  All Rights Reserved *
  3. * |. o.| ||          Written by Doug Walker                                 *
  4. * | .  | ||          The Software Distillery                                *
  5. * | o  | ||          235 Trillingham Lane                                   *
  6. * |  . |//           Cary, NC 27513                                         *
  7. * ======             BBS:(919)-471-6436                                     *
  8. \* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  9.  
  10. #include "netdnet.h"
  11. #include "handler.h"
  12.  
  13. #ifdef CPR
  14. char *dbgwind = "CON:0/0/640/160/NETDNET-HANDLER/a";
  15. #endif
  16.  
  17. #if 1
  18.  
  19. int ReSync(global, ioptr)
  20. GLOBAL global;
  21. APTR ioptr;
  22. {
  23.    TermRDevice(global, 1);
  24.    return(InitRDevice(global));
  25. }
  26.  
  27. #else
  28.  
  29. int ReSync(global, ioptr)
  30. GLOBAL global;
  31. APTR ioptr;
  32. {
  33.    return(1);
  34. }
  35.  
  36. #endif
  37.  
  38. int InitRDevice(global)
  39. GLOBAL global;
  40. {
  41.    struct MsgPort *chan;
  42.    struct NetNode *tmpnode;
  43.    struct RPacket RP;
  44.    static doinit = 1;
  45.  
  46.    if(!doinit) 
  47.    {
  48.       BUG(("InitRDevice: Init loop, exiting\n"))
  49.       return(1);
  50.    }
  51.  
  52.    doinit = 0;
  53.  
  54.    BUG(("InitRDevice: Initializing for DNET operation on unit %d\n",
  55.         global->unitnum));
  56.  
  57.    BUGP("InitRDevice: Entry")
  58.  
  59.    if(!(chan=DOpen(NULL, (uword)(PORT_FHANDLER), 20, 15)))
  60.    {
  61.       BUG(("********ERROR: Can't DOpen!!\n"));
  62.       BUGR("Can't open channel!")
  63.    }
  64.    if(chan) DQueue((struct DChannel *)chan, 32);/* Is this really necessary? */
  65.    BUG(("DNET Channel %lx open\n", chan));
  66.  
  67.    if(!global->netchain.next)
  68.    {
  69.       if(tmpnode=AddNode(global, "\3Foo", (APTR)chan))
  70.          strcpy(tmpnode->devname, "ROOT:");
  71.    }
  72.    else if(chan)
  73.    {
  74.       /* Preserve state of global->RP */
  75.        memcpy((char *)&RP, (char *)&global->RP, sizeof(struct RPacket));
  76.  
  77.       for(tmpnode=global->netchain.next; tmpnode; tmpnode=tmpnode->next)
  78.       {
  79.          BUG(("ReSync: Trying to resync '%s'\n", tmpnode->devname))
  80.    
  81.          global->RP.Type = ACTION_NETWORK_KLUDGE;
  82.          strcpy(global->RP.Data, tmpnode->devname);
  83.          global->RP.DLen = strlen(global->RP.Data);
  84.          tmpnode->RootLock.RDevice = (RPTR)1L;
  85.          tmpnode->ioptr = (APTR)chan;
  86.          tmpnode->status = NODE_UP;
  87.          if(RemotePacket(global, &tmpnode->RootLock))
  88.          {
  89.             tmpnode->status = NODE_CRASHED;
  90.             BUG(("ReSync: Failed\n"))
  91.          }
  92.       }
  93.       memcpy((char *)&global->RP, (char *)&RP, sizeof(struct RPacket));
  94.    }
  95.  
  96.  
  97.    doinit = 1;
  98.  
  99.    BUGP("InitRDevice: Exit")
  100.  
  101.    return(chan != NULL);
  102. }
  103.  
  104. int TermRDevice(global, status)
  105. GLOBAL global;
  106. int status;
  107. {
  108.    struct NetNode *netnode;
  109.  
  110.    for(netnode=global->netchain.next; netnode; netnode=netnode->next)
  111.    {
  112.       if(netnode->ioptr)
  113.       {
  114.          netnode->status = NODE_DEAD;
  115.          if(!status) DClose((struct DChannel *)netnode->ioptr);
  116.          netnode->ioptr = NULL;
  117.       }
  118.    }
  119.  
  120.    return(0);
  121. }
  122.  
  123. void ActNetHello(global, pkt)
  124. GLOBAL global;
  125. struct DosPacket *pkt;
  126. {
  127. }
  128.